{% extends "master.html" %}

{% block title %}Номын бүртгэлийн мэдээлэлд өөрчлөлт оруулах{% endblock %}

{% block script %}
<script type="text/javascript">
function saveBookData()
{
	document.forms['save_book_data'].submit();
}

function deleteLanguage(id)
{
	window.location.href = '/delete_language?id=' + id;
}

function deleteCurrency(id)
{
	window.location.href = '/delete_currency?id=' + id;
}

function deleteGenre(id)
{
	window.location.href = '/delete_genre?id=' + id;
}

function deleteSubject(id)
{
	window.location.href = '/delete_subject?id=' + id;
}
</script>
{% endblock %}

{% block content %}
	{% if user %}
		<form name="save_book_data" method="POST">
			<table align="center">
				<tbody>
					<tr>
						<td><center><strong><p>Номын бүртгэлийн мэдээлэлд өөрчлөлт оруулах</p></strong></center></td>
					</tr>
				</tbody>
			</table>
			<table align="center">
				<tbody>
					<tr>
						<td>Номын бичигдсэн хэл: </td>
						<td><input type="text" name="language" /></td>
						<td><input type="button" value="Хадгалах" onclick="saveBookData()" /></td>
					</tr>
					{% for language in language_list %}
						<tr>
							<td></td>
							<td>{{ language.language }}</td>
							<td><a href="javascript:deleteLanguage({{ language.key.id }})"><img src="images/delete.png" width="16" height="16" title="Устгах" /></td>
						</tr>
					{% endfor %}
					<tr>
						<td>Төлбөрийн хийх валют: </td>
						<td><input type="text" name="currency" /></td>
						<td><input type="button" value="Хадгалах" onclick="saveBookData()" /></td>
					</tr>
					{% for currency in currency_list %}
						<tr>
							<td></td>
							<td>{{ currency.currency }}</td>
							<td><a href="javascript:deleteCurrency({{ currency.key.id }})"><img src="images/delete.png" width="16" height="16" title="Устгах" /></td>
						</tr>
					{% endfor %}
					<tr>
						<td>Номын төрөл: </td>
						<td><input type="text" name="genre" /></td>
						<td><input type="button" value="Хадгалах" onclick="saveBookData()" /></td>
					</tr>
					{% for genre in genre_list %}
						<tr>
							<td></td>
							<td>
								<label><input type="radio" name="chosen_genre" value="{{ genre.genre }}" />{{ genre.genre }}</label>
							</td>
							<td><a href="javascript:deleteGenre({{ genre.key.id }})"><img src="images/delete.png" width="16" height="16" title="Устгах" /></td>
						</tr>
					{% endfor %}
					<tr>
						<td>Номын сэдэв: </td>
						<td><input type="text" name="subject" /></td>
						<td><input type="button" value="Хадгалах" onclick="saveBookData()" /></td>
					</tr>
				</tbody>
			</table>
			<table align="center">
				<tbody>
					{% for genre in genre_list %}
						<tr>
							<td colspan="2"><center><strong><p>{{ genre.genre }}</p></strong></center></td>
						</tr>
						{% for subject in subject_list %}
							{% ifequal genre.genre subject.genre.genre %}
								<tr>
									<td>{{ subject.subject }}</td>
									<td><a href="javascript:deleteSubject({{ subject.key.id }})"><img src="images/delete.png" width="16" height="16" title="Устгах" /></td>
								</tr>
							{% endifequal %}
						{% endfor %}
					{% endfor %}
				</tbody>
			</table>
		</form>
	{% endif %}
{% endblock %}

{% block sidebar %}{% include "admin.html" %}{% endblock %}